package com.yztc.orangeentertainment.ui.main.subscribefragment.starfragment;


import android.content.Context;

import com.yztc.orangeentertainment.adapter.SubStarAdapter;
import com.yztc.orangeentertainment.bean.subscribebean.StarBean;
import com.yztc.orangeentertainment.config.SubscribeUrlConfig;

import java.util.List;
import java.util.Map;


/**
 * Created by My on 2016/10/5.
 * 订阅明星presenter
 */
public class StarPresenter implements StarContract.Presenter {
    private StarContract.View view;
    private StarModle modle;
    private int index;

    public StarPresenter(StarContract.View view,int index) {
        this.view = view;
        this.modle = new StarModle();
        this.index=index;
    }

    @Override
    public void getStarFromNet(Map<String,String> map,final Context context) {

        modle.getStarAll(index,SubscribeUrlConfig.PATH.URL_TYPE, map, new com.yztc.orangeentertainment.ui.main.subscribefragment.starfragment.OnLoadTopListener() {
            @Override
            public void onSuccess(List<StarBean> list) {
                //将数据传到adapter
                view.sendToAdapter(new SubStarAdapter(list, context),list);
            }

            @Override
            public void onFailure(Exception e) {
                view.onLoadStarFail(e.getMessage() + "");
            }
        }, context);
    }

    @Override
    public void getStarFromDb() {
    }
}
